Nuke DOS newlines form pocketfms_wp.c
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Thu, 14 Apr 2011 01:35:42 +0000 (01:35 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Thu, 14 Apr 2011 01:35:42 +0000 (01:35 +0000)
gpsbabel/pocketfms_wp.c

index c51c2e2836c71d356101832b6d0deb4d74aa730d..ec05c52202e5ff9dc17db162fa23c72ef0b5fde7 100755 (executable)
-/*\r
-       PocketFMS waypoint text files (wpt).\r
-\r
-       Copyright (C) 2009 Tobias Kretschmar, tobias.kretschmar@gmx.de\r
-\r
-       This program is free software; you can redistribute it and/or modify\r
-       it under the terms of the GNU General Public License as published by\r
-       the Free Software Foundation; either version 2 of the License, or\r
-       (at your option) any later version.\r
-\r
-       This program is distributed in the hope that it will be useful,\r
-       but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
-       GNU General Public License for more details.\r
-\r
-       You should have received a copy of the GNU General Public License\r
-       along with this program; if not, write to the Free Software\r
-       Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA\r
- */\r
-\r
-#include "defs.h"\r
-#include "csv_util.h"\r
-\r
-#define MYNAME "PocketFMS waypoint text file format"\r
-\r
-static gbfile *file_in, *file_out;\r
-\r
-static void\r
-rd_init(const char *fname)\r
-{\r
-       file_in = gbfopen_le(fname, "r", MYNAME);\r
-}\r
-\r
-double wppos_to_dec(char *value)\r
-{\r
-       if (strstr(value, "°") == NULL)\r
-               return atof(value);\r
-       else \r
-       {\r
-               int degrees, minutes;\r
-               float seconds;\r
-               int sign = 1;\r
-\r
-               if (toupper(value[0]) == 'N' || toupper(value[0]) == 'E' || value[0] == '+')\r
-               {\r
-                       value = &value[1];\r
-               }\r
-               else if (toupper(value[0]) == 'S' || toupper(value[0]) == 'W' || value[0] == '-')\r
-               {\r
-                       value = &value[1];\r
-                       sign = -1;\r
-               }\r
-\r
-               sscanf(value, "%d°%d'%f\"", &degrees, &minutes, &seconds);\r
-               return sign * (degrees + ((float)minutes / 60) + (seconds / 3600));\r
-       }\r
-}\r
-\r
-static void\r
-data_read(void)\r
-{\r
-       char *buff;\r
-       int linecount = 0;\r
-       while ((buff = gbfgetstr(file_in))) {\r
-               char *s;\r
-               waypoint *wpt;\r
-               rtrim(buff);\r
-               if (strlen(buff) == 0)\r
-                       break;\r
-               linecount++;\r
-               wpt = waypt_new();\r
-               s = buff;\r
-               s = csv_lineparse(s, "\\w", "", linecount);\r
-                       wpt->shortname = xstrdup(s);\r
-               s = csv_lineparse(NULL, "\\w", "", linecount);\r
-                       wpt->latitude = wppos_to_dec(s);\r
-               s = csv_lineparse(NULL, "\\w", "", linecount);\r
-                       wpt->longitude = wppos_to_dec(s);\r
-                       waypt_add(wpt);\r
-       }\r
-}\r
-\r
-static void\r
-rd_deinit(void)\r
-{\r
-       gbfclose(file_in);\r
-}\r
-\r
-static void\r
-wr_init(const char *fname)\r
-{\r
-       file_out = gbfopen_le(fname, "w", MYNAME);\r
-}\r
-\r
-static void\r
-enigma_waypt_disp(const waypoint *wpt)\r
-{\r
-       gbfprintf(file_out, "%s %f %f\n", wpt->shortname, wpt->latitude, wpt->longitude);\r
-}\r
-\r
-static void\r
-data_write(void)\r
-{\r
-       waypt_disp_all(enigma_waypt_disp);\r
-}\r
-\r
-static void\r
-wr_deinit(void)\r
-{\r
-       gbfclose(file_out);\r
-}\r
-\r
-ff_vecs_t pocketfms_wp_vecs = {\r
-               ff_type_file,\r
-       { \r
-               ff_cap_read | ff_cap_write,     /* waypoints */\r
-               ff_cap_none,                    /* tracks */\r
-               ff_cap_none,                    /* routes */\r
-       },\r
-               rd_init,\r
-               wr_init,\r
-               rd_deinit,\r
-               wr_deinit,\r
-               data_read,\r
-               data_write,\r
-               NULL,\r
-               NULL,\r
-       CET_CHARSET_ASCII, 0    /* CET-REVIEW */\r
-};\r
+/*
+       PocketFMS waypoint text files (wpt).
+
+       Copyright (C) 2009 Tobias Kretschmar, tobias.kretschmar@gmx.de
+
+       This program is free software; you can redistribute it and/or modify
+       it under the terms of the GNU General Public License as published by
+       the Free Software Foundation; either version 2 of the License, or
+       (at your option) any later version.
+
+       This program is distributed in the hope that it will be useful,
+       but WITHOUT ANY WARRANTY; without even the implied warranty of
+       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+       GNU General Public License for more details.
+
+       You should have received a copy of the GNU General Public License
+       along with this program; if not, write to the Free Software
+       Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA
+ */
+
+#include "defs.h"
+#include "csv_util.h"
+
+#define MYNAME "PocketFMS waypoint text file format"
+
+static gbfile *file_in, *file_out;
+
+static void
+rd_init(const char *fname)
+{
+       file_in = gbfopen_le(fname, "r", MYNAME);
+}
+
+double wppos_to_dec(char *value)
+{
+       if (strstr(value, "°") == NULL)
+               return atof(value);
+       else 
+       {
+               int degrees, minutes;
+               float seconds;
+               int sign = 1;
+
+               if (toupper(value[0]) == 'N' || toupper(value[0]) == 'E' || value[0] == '+')
+               {
+                       value = &value[1];
+               }
+               else if (toupper(value[0]) == 'S' || toupper(value[0]) == 'W' || value[0] == '-')
+               {
+                       value = &value[1];
+                       sign = -1;
+               }
+
+               sscanf(value, "%d°%d'%f\"", &degrees, &minutes, &seconds);
+               return sign * (degrees + ((float)minutes / 60) + (seconds / 3600));
+       }
+}
+
+static void
+data_read(void)
+{
+       char *buff;
+       int linecount = 0;
+       while ((buff = gbfgetstr(file_in))) {
+               char *s;
+               waypoint *wpt;
+               rtrim(buff);
+               if (strlen(buff) == 0)
+                       break;
+               linecount++;
+               wpt = waypt_new();
+               s = buff;
+               s = csv_lineparse(s, "\\w", "", linecount);
+                       wpt->shortname = xstrdup(s);
+               s = csv_lineparse(NULL, "\\w", "", linecount);
+                       wpt->latitude = wppos_to_dec(s);
+               s = csv_lineparse(NULL, "\\w", "", linecount);
+                       wpt->longitude = wppos_to_dec(s);
+                       waypt_add(wpt);
+       }
+}
+
+static void
+rd_deinit(void)
+{
+       gbfclose(file_in);
+}
+
+static void
+wr_init(const char *fname)
+{
+       file_out = gbfopen_le(fname, "w", MYNAME);
+}
+
+static void
+enigma_waypt_disp(const waypoint *wpt)
+{
+       gbfprintf(file_out, "%s %f %f\n", wpt->shortname, wpt->latitude, wpt->longitude);
+}
+
+static void
+data_write(void)
+{
+       waypt_disp_all(enigma_waypt_disp);
+}
+
+static void
+wr_deinit(void)
+{
+       gbfclose(file_out);
+}
+
+ff_vecs_t pocketfms_wp_vecs = {
+               ff_type_file,
+       { 
+               ff_cap_read | ff_cap_write,     /* waypoints */
+               ff_cap_none,                    /* tracks */
+               ff_cap_none,                    /* routes */
+       },
+               rd_init,
+               wr_init,
+               rd_deinit,
+               wr_deinit,
+               data_read,
+               data_write,
+               NULL,
+               NULL,
+       CET_CHARSET_ASCII, 0    /* CET-REVIEW */
+};